#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int maxHeightOfTriangle(int red, int blue) {
        int blue1 = blue, blue2 = blue;
        int red1 = red, red2 = red;
        int res1 = 0, res2 = 0;
        int high = 1;
        while (blue1 >= high || blue2 >= high || red1 >= high || red2 >= high)
        {
            if (high % 2 != 0)
            {
                if (blue1 >= high)
                {
                    blue1 -= high;
                    ++res1;
                }
                else red1 = blue1 = 0;
                if (red2 >= high)
                {
                    red2 -= high;
                    ++res2;
                }
                else red2 = blue2 = 0;
            }
            else
            {
                if (red1 >= high)
                {
                    red1 -= high;
                    ++res1;
                }
                else red1 = blue1 = 0;
                if (blue2 >= high)
                {
                    ++res2;
                    blue2 -= high;
                }
                else red2 = blue2 = 0;
            }
            ++high;
        }
        cout << res1 << ' ' << res2 << endl;
        return max(res1, res2);
    }
};